# encoding: utf-8
""" 
@version: v1.0 
@author: autumner 
@license: Apache Licence  
@contact: 18322313385@163.com 
@site: https://gitee.com/autumner/pythoncookbook.git 
@software: PyCharm Community Edition 
@file: downmovie.py 
@time: 18-8-30 下午4:07
"""
"""
说明：
腾讯vip电影下载方法
1.复制vip电影地址
2.打开谷歌浏览器输入http://www.qmaile.com/，ctrl+shift+c打开分析工具
3.粘贴电影地址，从分析工具network标签找到*.ts地址复制下来
4.通过下面代码实现。
"""


import requests
from multiprocessing import Pool


# 1.下载电影片段
def downM(i):
    url = "https://letv.com-v-letv.com/20180809/7174_ecfc8ad7/1000k/hls/c80ef66bd6c%03d.ts" % i
    headers = {
        "User-Agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"
    }
    print(url)
    # print(headers)
    r = requests.get(url, headers=headers)
    # print(r.content)
    with open('./xfmsl/{}'.format(url[-10:]), 'ab') as f:
        f.write(r.content)

if __name__ == "__main__":
    pool = Pool(20)
    for i in range(1369):
        pool.apply_async(downM, (i,))
    pool.close()
    pool.join()